package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizGoodsCategory;
import com.ruoyi.biz.service.IBizGoodsCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 商品类别信息Controller
 * 
 * @author tds
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/biz/goodsCategory")
public class BizGoodsCategoryController extends BaseController
{
    @Autowired
    private IBizGoodsCategoryService bizGoodsCategoryService;

    /**
     * 查询商品类别信息列表
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:list')")
    @GetMapping("/list")
    public AjaxResult list(BizGoodsCategory bizGoodsCategory)
    {
        List<BizGoodsCategory> list = bizGoodsCategoryService.selectBizGoodsCategoryList(bizGoodsCategory);
        return success(list);
    }

    /**
     * 导出商品类别信息列表
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:export')")
    @Log(title = "商品类别信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizGoodsCategory bizGoodsCategory)
    {
        List<BizGoodsCategory> list = bizGoodsCategoryService.selectBizGoodsCategoryList(bizGoodsCategory);
        ExcelUtil<BizGoodsCategory> util = new ExcelUtil<BizGoodsCategory>(BizGoodsCategory.class);
        util.exportExcel(response, list, "商品类别信息数据");
    }

    /**
     * 获取商品类别信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:query')")
    @GetMapping(value = "/{goodsId}")
    public AjaxResult getInfo(@PathVariable("goodsId") Long goodsId)
    {
        return success(bizGoodsCategoryService.selectBizGoodsCategoryByGoodsId(goodsId));
    }

    /**
     * 新增商品类别信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:add')")
    @Log(title = "商品类别信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizGoodsCategory bizGoodsCategory)
    {
        return toAjax(bizGoodsCategoryService.insertBizGoodsCategory(bizGoodsCategory));
    }

    /**
     * 修改商品类别信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:edit')")
    @Log(title = "商品类别信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizGoodsCategory bizGoodsCategory)
    {
        return toAjax(bizGoodsCategoryService.updateBizGoodsCategory(bizGoodsCategory));
    }

    /**
     * 删除商品类别信息
     */
    @PreAuthorize("@ss.hasPermi('biz:goodsCategory:remove')")
    @Log(title = "商品类别信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsIds}")
    public AjaxResult remove(@PathVariable Long[] goodsIds)
    {
        return toAjax(bizGoodsCategoryService.deleteBizGoodsCategoryByGoodsIds(goodsIds));
    }
}
